|
|
 |
|
|
|
|
For i = 1 To 4
value = 0#
For j = 1 To 4
value = value + V(j) * M(j, i)
Next j
Result(i) = value
Next i
' Renormalize the point.
' Note that value still holds Result(4). Result(1) = Result(1) / value
Result(2) = Result(2) / value
Result(3) = Result(3) / value
Result(4) = 1#
End Sub
' Multiply two matrices together. The matrices
' may not contain 0, 0, 0, 1 in their last columns. Public Sub m3MatMultiplyFull(Result() As Single, _
A() As Single, B() As Single)
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim value As Single
For i = 1 To 4
For j = 1 To 4
value = 0#
For k = 1 To 4
value = value + A(i, k) * B(k, j)
Next k
Result(i, j) = value
Next j
Next i
End Sub |
|
|
|
|
|
|
|
|
These subroutines and others that manipulate three-dimensional points and matrices are contained in module M3Ops.bas. |
|
|
|
|
|
|
|
|
Generalizing a two-dimensional translation matrix for the three-dimensional case is easy. To translate a point by distance Tx in the direction of the X axis, Ty along the Y axis, and Tz along the Z axis, you can multiply the point by the transformation matrix: |
|
|
|
|
|